﻿using DapperExtensions;
using Nova_Common.Extend;
using Nova_DAL;
using Nova_MOD;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Nova_BLL
{
    public class TCommandsDetailBll
    {
        private readonly TCommandsDetailDal dal = new TCommandsDetailDal();

        public bool InsertEntity(TCommandsDetail entity)
        {
            string id = dal.Insert(entity);
            return id.IsEmpty();
        }

        public bool InsertEntity(long taskId, long DETAIL_PID, string STORE_PID, decimal Num = 0)
        {                                        
            TCommandsDetail entity = new TCommandsDetail();
            entity.TaskID = taskId;
            entity.DETAIL_PID = DETAIL_PID;
            entity.STORE_PID = STORE_PID;
            entity.MAT_NUM = Num;
            string id = dal.Insert(entity);
            return !id.IsEmpty();
        }

        public bool UpdateEntity(TCommandsDetail entity)
        {
            return dal.Update(entity);
        }

        public TCommandsDetail GetByTaskId(long taskId)
        {
            var predicate = Predicates.Field<TCommandsDetail>(t => t.TaskID, Operator.Eq, taskId);
            return dal.GetByField(predicate);
        }
    }
}
